/*
2021-11-8
https://ac.nowcoder.com/acm/contest/22551/B
*/
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int T, x;
    cin >> T;
    while (T--)
    {
        cin >> x;
        if (x == 10) cout << "SSS" << endl;
        else if (x >= 8 && x <= 9) cout << "SS" << endl;
        else if (x >= 5 && x <= 7) cout << "S" << endl;
        else if (x >= 1 && x <= 4) cout << "A" << endl;
        else if (x == 0) cout << "B" << endl;
    }
    return 0;
}